home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / menu-slide-11-p / MenuSlide / Slideoff < prev   
Encoding:
Text File  |  1994-11-23  |  2.9 KB  |  106 lines  |  [TEXT/ttxt]

  1. X-Sender: chewey@nesw.mv.com (Unverified)
  2. Mime-Version: 1.0
  3. Date: Tue, 5 Jul 1994 22:08:25 -0500
  4. To: Hugh.Fisher@anu.edu.au
  5. From: chewey@nesw.MV.COM (Matthew E. Axsom)
  6. Subject: Slideoff
  7.  
  8. Hugh,
  9.  
  10. Sorry for taking so long to get back to you.  I added 2 lines of code to
  11. your slideoff routine so that it now looks for the next menu insertion
  12. point and uses that as it's sliding point.  Hopefully this should keep
  13. clocks and other extra system menu beasties from sliding w/the apps menus.
  14.  
  15. The code is in C (straight out of my app library).  If you have any
  16. questions about the code or how it works (should be pretty straight
  17. forward) let me know.  There is a way to detect the left edge of the system
  18. menus, but then you would have to look for the clock.  Using the next menu
  19. insertion point should work pretty well.
  20.  
  21. If I have any spare time I might write an init to do this in all app.
  22. Might even be able to slide off the old and slide in the new.  Maybe ;->
  23.  
  24. Thanks again for reviving this interface concept.
  25.  
  26. Cheers,
  27.  
  28. -Chewey
  29.  
  30.  
  31.  
  32. Content-Type: text/plain; name="Slideoff.c"; charset="us-ascii"
  33. Content-Disposition: attachment; filename="Slideoff.c"
  34.  
  35. #define LMGetMenuList() (* (Handle *) 0x0A1C)
  36.  
  37. // these are my own data structures for parsing the menu list
  38. typedef struct {
  39.     MenuHandle    mh;            
  40.     short        startLeft;    // Position from the left where this menu starts
  41. }menuRec,*menuRecPtr,**menuRecHand;
  42.  
  43. typedef struct {
  44.     short    size;        // div sizeof(menuRec) for number of items
  45.     short    nextLeft;    // where next menu will go
  46.     short    filler;        // just junk
  47.     menuRec    item[];        // a list of the above
  48. }menuListRec,*menuListPtr,**menuListHand;
  49.  
  50. static void slideMenuOff()
  51. {
  52.     GrafPtr            desktop;
  53.     short            rightEdge, step;
  54.     Rect            source, dest;
  55.     RgnHandle        saveGray, menuBox;
  56.     Ulong            now;
  57.     menuListHand    ml;
  58.  
  59. // An improved hack.  Uses the current apps menu list to find the right
  60. // most menu.  - MEA 07/05/94
  61.     ml=(menuListHand)LMGetMenuList();
  62.     rightEdge = (*ml)->nextLeft;
  63.     
  64. // Need to fool around with the desktop. This is similar to hiding the menu bar.
  65.     GetWMgrPort(&desktop);
  66.     saveGray = NewRgn();
  67.     CopyRgn(GetGrayRgn(), saveGray);
  68.     SetRect(&source, 0, 0, qd.screenBits.bounds.right, LMGetMBarHeight());
  69.     menuBox = NewRgn();
  70.     RectRgn(menuBox, &source);
  71.     UnionRgn(GetGrayRgn(), menuBox, GetGrayRgn());
  72.     
  73. // OK, now scroll the menu off the screen
  74.     SetRect(&source, 0, 0, rightEdge, LMGetMBarHeight());
  75.     dest = source;
  76.     step = 1;
  77.     
  78.     while (dest.right > 0) {
  79.         OffsetRect(&dest, -step, 0);
  80.         CopyBits(&desktop->portBits,&desktop->portBits, &source, &dest, srcCopy, nil);
  81.         
  82. // Wait a tick
  83.         now = TickCount();
  84.         while (now == TickCount())
  85.             ;
  86.             
  87.         step <<=1;
  88.     }
  89.     
  90. // And put things back
  91.     CopyRgn(saveGray, GetGrayRgn());
  92.     DisposeRgn(saveGray);
  93.     DisposeRgn(menuBox);
  94. }
  95.  
  96.  
  97.  
  98. struct Matthew: E, Axsom {  // chewey@nesw.mv.com
  99.     Matthew(void) : E(), Axsom() {}
  100.     Boolean macSoftwareEngineer(long future) {return future == Random();}
  101.     Boolean newEnglandSoftwareWorks(StringPtr name) {return true;}
  102. };
  103.  
  104.  
  105.  
  106.